---
title: "Flexdashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(p8105.datasets)
library(tidyverse)
library(plotly)
```
```{r}
#The data is cleaned and subset to weather station with data entry in winter (Dec-Feb) from 2000 to 2010
data("ny_noaa")
ny_noaa=ny_noaa%>%
janitor::clean_names()%>%
filter(
!is.na(tmin),
!is.na(tmax)
)%>%
separate(date, into=c("year","month","day"))%>%
mutate(tmin=as.numeric(tmin),
tmax=as.numeric(tmax),
tmin=tmin/10,
tmax=tmax/10,
prcp=prcp/10,
year=as.numeric(year),
month=tolower(month.abb[as.numeric(month)]))%>%
filter(year %in% 2000:2010,
month %in% c("dec", "jan", "feb"))
```
Column {data-width=650}
-----------------------------------------------------------------------
### Average Percipitation during Winter 2000-2010
```{r, warning=FALSE}
ny_noaa %>%
group_by(id)%>%
na.omit()%>%
summarise(avg_prcp=mean(prcp))%>%
mutate(id = fct_reorder(id, avg_prcp))%>%
plot_ly(x=~id, y=~avg_prcp, color=~id, type="bar", mode="markers")%>%
layout(xaxis=list(title="Weather Station ID"), yaxis=list(title="Average Percipitation"))
```
Column {data-width=350}
-----------------------------------------------------------------------
### Yearly Distribution of Snow Depth from 2000 to 2010
```{r, warning=FALSE}
ny_noaa%>%
plot_ly(x=~year, y=~snwd, type="box", colors="viridis")%>%
layout(xaxis=list(title="Year"), yaxis=list(title="Snow Depth"))
```
### Temperatue Range and Snowfall
```{r, warning=FALSE}
ny_noaa %>%
group_by(id)%>%
na.omit()%>%
summarise(avg_tmin=mean(tmin), avg_tmax=mean(tmax), avg_snowfall=mean(snow))%>%
plot_ly(x=~avg_tmin, y=~avg_tmax, color=~avg_snowfall, type="scatter", mode="markers")%>%
layout(xaxis=list(title="Average Min Temperature"), yaxis=list(title="Average Max Temperature"))
```